<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta content="telephone=no,email=no" name="format-detection">
<meta name="wap-font-scale" content="no">
<title>注册</title>
<!-- 公用样式css -->
<link href="css/base.css" rel="stylesheet" type="text/css" />
<!-- 界面引入css -->
<link href="css/interests-member.css" rel="stylesheet" type="text/css" />
<link href="css/supplement.css" rel="stylesheet" type="text/css" />
</head>
<body style="background-color: #fff;">
	<c:if test='${getOpenid eq "yes"}'>
		<script>
            window.location.replace("https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=http://yk.aljb.net/home/index&response_type=code&scope=snsapi_base&state=1#wechat_redirect");
		</script>
	</c:if>

	<div class="main">
		<div class="head-portrait">
			<img class="portrait-img" src="${userImg}" width="50" height="50" />
			<p>${userName}</p>
		</div>
		<ul class="adjun-list-a">
			<li class="adjun-left-a"><img class="adjun-img" src="images/phone.png" width="26" height="26" /></li>
			<li class="adjun-right-a"><input name="Phone" type="tel" id="Phone" class="adjun-input" placeholder="输入手机号码" /></li>
		</ul>
		<ul class="adjun-list-a">
			<li class="adjun-left-a"><img class="adjun-img" src="images/security.png" width="26" height="26" /></li>
			<li class="adjun-right-a"><input name="Captcha" id="Captcha" type="text" class="adjun-input" placeholder="输入验证码" /></li>
			<li class="adjun-right-b" onclick="_getCode()" id="codeLi" style="cursor:pointer;">获取验证码</li>
		</ul>
		<div class="pay-button-all">
			<a class="pay-button" onclick="_submit()" >确定</a>
		</div>
	</div>
	<form id="submitForm" method="post" action="home/index">
   		<input type="hidden" value="${hotelKey}" id="hotelKey" name="hotelKey"/>
		<input type="hidden" value="${startDate}" id="startDate" name="startDate"/>
		<input type="hidden" value="${endDate}" id="endDate" name="endDate"/>
		<input type="hidden" value="${cityName}" id="cityName" name="cityName"/>
		<input type="hidden" value="${city}" id="city" name="city"/>
		<input type="hidden" value="${lng}" id="lng" name="lng"/>
		<input type="hidden" value="${lat}" id="lat" name="lat"/>
   	</form>
</body>
<script src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/artDialog/artDialog.source.js?skin=simple"></script>
<script type="text/javascript" src="js/artDialog/plugins/iframeTools.source.js"></script>
<script type="text/javascript">
	function _getCode(){
          djs();
		  $.ajax({
            url:"<%=basePath%>home/applySMS",
            type:"post",
            data:"Phone="+$("#Phone").val(),
            success:function(data){
                if(data=="success"){
                	$("#codeLi").attr("disabled",true);
                	//操作成功！
                }else {
                	//操作异常，显示接口回传结果
                	art.dialog.tips(data);
                }
            },
            error:function(e){
                art.dialog.tips("操作异常");
            }
        });
	}
	function _submit(){
		 $.ajax({
            url:"<%=basePath%>home/register",
            type:"post",
            data:"Phone="+$("#Phone").val()+"&Captcha="+$("#Captcha").val(),
            success:function(data){
                if(data=="success"){
                    art.dialog.tips("注册成功");
                    $("#submitForm").submit();
                }else{
                    art.dialog.tips(data);
                }
            },
            error:function(e){
                art.dialog.tips("操作异常");
            }
        });
	}
	
	function djs(){
	  var timer=null;
	  var s=60;
	  function countDown(){
		  if(Number(s)==0){
		  		clearInterval(timer);
		  		$("#codeLi").html("获取验证码");
		  		$("#codeLi").attr("disabled",false);
		  }else{
		  	s--;
	   		s<10&&(s='0'+s);
		  }
	   	  $("#codeLi").html(s+"s后重新获取");
	  }
	  timer=setInterval(countDown,1000);
	}

</script>
</body>

</html>
